package com.cqfae.deploycentral.app.web.controller;

import com.cqfae.deploycentral.app.utils.GsonUtils;
import com.cqfae.deploycentral.app.services.CommonControllerService;
import com.cqfae.deploycentral.app.services.DeployHistoryService;
import com.cqfae.deploycentral.app.utils.NullUtil;
import com.cqfae.deploycentral.app.web.request.DeployActionRequest;
import com.cqfae.deploycentral.app.web.response.WebResponse;
import com.cqfae.deploycentral.app.web.vo.DeployHistoryVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author JIANGLU009
 * @since 1.0.0-snapshot
 */
@RestController
@RequestMapping("/deploy-central/deploy-history")
public class DeployHistoryController implements CommonControllerService<Object> {

    private static Logger logger = LoggerFactory.getLogger(DeployHistoryController.class);

    @Autowired
    private DeployHistoryService deployHistoryService;

    /**
     * 翻页查询
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/list-by-page")
    public WebResponse listByPage(DeployActionRequest request) {
        String requestJson = GsonUtils.getInstance().toJson(request);
        logger.info("==== listByPage ScheduledExecHistoryRequest :==== {}", requestJson);
        return getWebResponse(deployHistoryService.listByPage(request));
    }

    /**
     * 设置返回参数
     *
     * @param obj
     * @return
     */
    @Override
    public WebResponse getWebResponse(Object obj) {
        WebResponse webResponse = new WebResponse();
        if (NullUtil.isNotEmpty(obj)) {
            webResponse.setData(obj);
        }
        return webResponse;
    }


}
